<?php
	echo $template['partials']['clientForm'];
	
	//$this->firephp->log($schoolId, 'schoolId');
	//$this->firephp->log($offer, 'offer');
	
	//$this->firephp->log($GLOBALS,'GLOBALS');
?>


<!-- Buttons -->
<button id="rightButton">seguinte</button> 
<button id="leftButton">Anterior</button>
<button id="loadButton">Escolher Cliente</button>
<button id="clearButton">Limpar</button>
<!-- ******* -->


<!-- Table with a list of Clients -->
<div id="clientTableDialog" class="dialog">
	<table id="clientTable" class="dataTable">
		<thead>
			<tr>
				<th>Nome</th>
				<th>Morada</th>
				<th>eMail</th>
				<th>Telefone</th>
				<th>data de nascimento</th>
			</tr>
		</thead>
		<tbody>
			<!--  <td colspan="5" class="dataTables_empty">Loading data from server</td>-->
		</tbody>
	</table>
</div>
<!-- ******************* -->


<!-- Dialog to choose reservation options-->
<div id="reservationOptions" 	title="Opcoes adicionais" class="dialog">
	<form id="formOptions" class="formee">
		<fieldset>
			<div class="grid-3-12">
				<label>Transporte</label>
				<select id="transportOption">
					<option value="yes">sim</option>
					<option value="no">não</option>
				</select>
			</div>
			<div class="grid-12-12">
				<label>Extras</label>
				<ul id="extrasList" class="formee-list listWithExtras">
					<!--  
					<li><input type="checkbox" /><label>extra 1 (10 €)</label></li>
					<li><input type="checkbox" /><label>extra 2 (5 €)</label></li>
					<li><input type="checkbox" /><label>extra 3 (2 €)</label></li>
					-->
				</ul>
			</div>
		</fieldset>
	</form>
</div>
<!-- ******* -->


<!-- Others dialogs -->
<div id="noClientSelected" 		title="Alerta" 	class="dialog">nenhum cliente selecionado</div>
<div id="genericAlert" 			title="Alerta" 	class="dialog"> ... </div>
<div id="clientExistsAlert" 	title="Alerta" 	class="dialog"> Atenção! Já existe um cliente com este email</div>

<!-- ******* -->



<!--  <button id="tmpButton">tmp Action</button> -->







<script>

$(document).ready(function() {
	
	var offerId 	= <?php echo $offerId;?>;
	var classId 	= <?php echo $classId;?>;
	var userId 		= <?php echo $user->id;?>;
	var schoolId 	= <?php echo $schoolId;?>;

	ini();
	
	buttonEvents(offerId,classId,userId,schoolId);
	
	datatableConfig();

	//tmp();
});



function tmp() {

	// button for tests
	$('#tmpButton').on('click', function() {
		
		//var obj = { var1: 'value 1', var2: 'value 1', grpVar: { a: 'a', b: 'b' } };
		//var encoded = $.param(obj,true);
		fillFormWithTmpData();
	});
}



function fillFormWithTmpData() {
	
	var clientForm = $('#clientForm'); 

	clientId = clientForm.attr('data-id');

	console.log(clientId);

	clientForm.find('#clientName').val('tmpName');
	clientForm.find('#clientAddress').val('tmpAddress');
	clientForm.find('#clientEmail').val('tmpemail@mail.com');
	clientForm.find('#clientPhone').val('912349594');
	clientForm.find('#clientHeight').val('179');
	clientForm.find('#clientBirthday').val('1980-07-04');
	clientForm.find('#clientWeight').val('80');
	clientForm.find('#clientSex').val('m');
	clientForm.find('#clientNationality').val('portuguesa');
	clientForm.find('#clientInfo').val('tmp info about tmp client');
}

</script>

